const express = require("express");
const router = express.Router();
const middleware_auth = require("../../../middleware/auth");
const assert = require("http-assert");
const { resData } = require("../../../utils/format");
const middleware_permission = require("../../../middleware/permission");
const commodityModel = require("../../../models/Commodity");
module.exports = app => {
    /**
     * @apiGroup 小程序端/首页
     * @api {get}  通过分类获取商品
     */
    router.get("/getCommodityByCat/:cat", async (req, res) => {
        const { cat } = req.params;
        assert(cat, 400, "请传入商品id");
        let data = await commodityModel.find({ cat });
        res.send(resData(data));
    });

    app.use("/web/api/order", router);
};
